package org.makcro.sms.services.chat.base.dao;

import java.util.Date;

import org.makcro.sms.services.chat.model.Subscriber;

public interface SubscriberDao extends BasicDao<Subscriber>{

	/**
	 * Checks if user has a record in Subscriber's table and updates subscription date to current if true.
	 * 
	 * @param phonenumber
	 *            MSISDN of the subscriber
	 * @return true if does have active session, otherwise false
	 */
	public boolean checkIfHasActiveSessionAndUpdate(String phonenumber);

	/**
	 * Updates {@link Subscriber} by setting {@link Subscriber#setUnsubscribed(boolean)} to true where subscription date is before param lastMonth.
	 * 
	 * @param lastMonth
	 *            date representing limit for active subscriptions.
	 * @return number of updated (disabled) subscriptions
	 */
	public int disableExpiredSubscriptions(Date lastMonth);

	/**
	 * Disables subscription identified by MSISDN
	 * @param phonenumber
	 */
	public int disableSubscription(String phonenumber);

	/**
	 * Finds subscriber by it's phone number.
	 * 
	 * @param phonenumber
	 *            phone number of the subscriber
	 * @return instance of {@link Subscriber} if found, null otherwise.
	 */
	public Subscriber findByPhonenumber(String phonenumber);

}